﻿﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace SGArchiveSystem7xDB.Sql
{
    public class SGData
    {
        static SGArchiveSystem7xEntities conn;
        public static List<string[]> Get_ArchiveTypeCount()
        {
            conn = new SGArchiveSystem7xEntities();
            string connection = conn.Database.Connection.ConnectionString;
            SqlConnection sqlconn = new SqlConnection(connection);
            sqlconn.Open();
            try
            {
                SqlCommand cmd = new SqlCommand("select count(*) as count, arid from T_archiveaj group by arid", sqlconn);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);

                List<string[]> list = new List<string[]>();
                DataTable dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string[] strs = new string[2];
                    strs[0] = dr["count"].ToString();
                    strs[1] = dr["arid"].ToString();
                    list.Add(strs);
                }
                return list;
            }
            catch { return null; }
            finally
            {
                sqlconn.Close();
            }
        }
    }
}